import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
// 引入elementUi
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// 引入富文本编辑器
import vueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
// 引入本地样式
import '@/styles/index.scss'
Vue.use(vueQuillEditor)
// 使用插件
Vue.use(ElementUI)
Vue.config.productionTip = false

// 路由权限认证
router.beforeEach((to, from, next) => {
  // console.log(to)
  // console.log(from)
  // 获取到本地存储
  let mytoken = localStorage.getItem('mytoken')
  if (mytoken) {
    next()
  } else {
    // 没有登录，但在除了login页面以外的页面
    to.name === 'login' ? next() : next('/login')
  }
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
